package com.dz.controller.user;

import com.dz.entity.Category;
import com.dz.result.Result;
import com.dz.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 鄧浩奇
 * @classname CategoryController
 * @description
 * @since 2024/1/7 15:30
 **/

@Api(tags = "用户分类接口")
@RestController
@RequestMapping("/user/category")
public class UserCategoryController {

    private final CategoryService categoryService;

    @Autowired
    public UserCategoryController(CategoryService categoryService) {
        this.categoryService = categoryService;
    }

    @ApiOperation("C端 查询分类列表")
    @GetMapping("/list")
    public Result<List<Category>> list(Integer type) {
        List<Category> categories = categoryService.getListByType(type);
        return Result.success(categories);
    }
}
